#!/usr/bin/python
#***************************************************************************
# Copyright notice for this file:
#  Copyright (C) 2012 TheAxeMan
#  _______ _                               _    _
# |__   __| |     ___     /\          ___ | \  / |
#    | |  | |__  / _ \   /  \  __  _ / _ \|  \/  | __ _ _ __
#    | |  | '_ \|  __/  / /\ \ \ \/ |  __/| .  . |/ _` | '_ \
#    | |  | | | | (__/\/ ____ \ )  (| (__/| |\/| | (_| | | | |
#    |_|  |_| |_|\____/_/    \_._/\_.\____|_|  |_|\__,_|_| |_|
#
# Final Fantasy TAS scripts by TheAxeMan
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#***************************************************************************


import sys
import time

class StatusBar:
  def start(self, status_size, count):
    """
    Starts out the status bar and makes a blank to start the .s.
    status_size is the number of .s for full completion
    count is the number to count to for full completion
    """

    self.status_size = status_size
    self.status = 0
    self.count = count
    self.dot_count = 0
    self.start_time = time.time()

    quarter_status = self.status_size / 4
    status_bar = "|"
    for y in range(4):
      for x in range(quarter_status-1):
        status_bar += "-"
      if y < 3:
        status_bar += "+"
      else:
        status_bar += "|"
    print status_bar
    sys.stdout.write(" ")

  def finish(self):
    finish_time = time.time()
    print ""
    print "finished in",finish_time-self.start_time,"seconds"

  def incrementStatus(self):
    self.status += 1
    new_dot_count = int(self.status_size * ((self.status*1.0) / self.count))
    if new_dot_count > self.dot_count:
      self.dot_count = new_dot_count
      sys.stdout.write(".")
      sys.stdout.flush()

